import { addNameSpace } from './util'

const NAME_SPACE = 'TEMPLATE'

const addPrefix = addNameSpace(NAME_SPACE)

// 设置模板
export const SET_TEMPLATE = addPrefix('SET_TEMPLATE')

// 设置状态
export const SET_STATUS = addPrefix('SET_STATUS')

// 设置开始时间
export const SET_START_TIME = addPrefix('SET_START_TIME')

// 设置结束时间
export const SET_END_TIME = addPrefix('SET_END_TIME')

// 获取模板
export const GET_DATA = addPrefix('GET_DATA')

// 获取模板成功
export const GET_DATA_SUCCESS = addPrefix('GET_DATA_SUCCESS')

// 获取模板失败
export const GET_DATA_FAIL = addPrefix('GET_DATA_FAIL')

// 删除模板
export const DELETE_TEMPLATE = addPrefix('DELETE_TEMPLATE')

// 删除模板成功
export const DELETE_TEMPLATE_SUCCESS = addPrefix('DELETE_TEMPLATE_SUCCESS')

// 删除模板失败
export const DELETE_TEMPLATE_FAIL = addPrefix('DELETE_TEMPLATE_FAIL')

// 设置page num
export const SET_PAGE_NUM = addPrefix('SET_PAGE_NUM')

export const setTemplate = (template) => ({ type: SET_TEMPLATE, template })

export const setStatus = (status) => ({ type: SET_STATUS, status })

export const setStartTime = (startTime) => ({ type: SET_START_TIME, startTime })

export const setEndTime = (endTime) => ({ type: SET_END_TIME, endTime })

export const getData = () => ({ type: GET_DATA })

export const getDataSuccess = (data) => ({ type: GET_DATA_SUCCESS, data })

export const getDataFail = () => ({ type: GET_DATA_FAIL })

export const deleteTemplate = (data) => ({ type: DELETE_TEMPLATE, data })

export const deleteTemplateSuccess = () => ({ type: DELETE_TEMPLATE_SUCCESS })

export const deleteTemplateFail = () => ({ type: DELETE_TEMPLATE_FAIL })

export const setPageNum = (pageNum) => ({ type: SET_PAGE_NUM, pageNum })

export default {
  setTemplate,
  setStatus,
  setStartTime,
  setEndTime,
  getData,
  getDataSuccess,
  getDataFail,
  deleteTemplate,
  deleteTemplateSuccess,
  deleteTemplateFail,
  setPageNum,
}